Purpose: learn how to get a list of available printers and use this to successfully print your labels through API.
Having trouble with label printing (size, alignment, or barcodes)? Check
our
Print Client App configuration & troubleshooting
guide
Important: that the print client app needs to be opened and that you provide the path of where your pdf file is located.
Step 1: Find your printer(s)
Get a list of available printers with the following sample call:
curl 'http://127.0.0.1:1903/printers ' -H 'Accept: application/jsonThe response will show a list of available printers including their "id". See example below:
[
{
"default": true,
"id": "HP_LaserJet_500_colorMFP_M570dw",
"name": "HP LaserJet 500 colorMFP M570dw"
},
{
"default": false,
"id": "DYMO_LabelWriter_4XL",
"name": "DYMO LabelWriter 4XL"
},
{
"default": false,
"id": "Zebra_Technologies_ZTC_GK420d",
"name": "Zebra Technologies ZTC GK420d"
}
]The id of the printer will later function as input for the POST Print a document request.
Step 2: Print your documents
For more details on printing documents through API we forward you to our API documentation.
-
Make sure to add the id of the printer from Step 1 in the following URL:
url ='http://127.0.0.1:1903/printers/<insert printer ID>/print - Next, add the path to the location of the PDF document
- Use the example in the code block below to complete your request
(The example shown below is written in Python.)
import requests
url ='http://127.0.0.1:1903/printers/HP_LaserJet_500_colorMFP_M570dw/print'
file = {
'file': open('C:/path/to/test.pdf', 'rb'),
}
headers = {
'Accept': 'application/json'
}
r = requests.post(url, headers=headers, files=file)
print(r)After a successful response your label will be printed.
For more information on our API, we advise you to take a look at our API Documentation.